package com.itheima.interface3;
//打印全班信息 包含男女人数 打印全班平均分（去掉最高分和最低分）
public class Function2 implements  Function{
    Student[] students;
    public Function2(Student[] students)
    {
        this.students=students;
    }
    @Override
    public void printAllscore() {
        int man=0;
        for(int i=0;i<students.length;i++)
        {
            System.out.println(students[i].getName()+"---"+students[i].getAge()+"---"+students[i].getScore());
            if(students[i].getSex()=="男")
            {
                man++;
            }
        }
        System.out.println("男生人数为："+man+"女生人数"+(students.length-man));
    }

    @Override
    public void printAvgScore() {
        double sum=students[0].getScore();
        double max=students[0].getScore();
        double min=students[0].getScore();
        for(int i=1;i<students.length;i++)
        {
            sum+=students[i].getScore();
            if(students[i].getScore()>max)
            {
                max=students[i].getScore();
            }
            if(students[i].getScore()<min)
            {
                min=students[i].getScore();
            }
        }
        System.out.println("平均分是:"+(sum-max-min)/(students.length-2));
    }
}
